{{include file="header.html"}}
{{include file="menu.html"}}
		<!-- 右边侧边栏 -->
		<div class="right">
			<!-- 个人信息部分 -->
			<div class="item">
				<form action="index.php?app=personal" name="myform" method="post" class="ajaxSubmit" onsubmit="return false" id="myform">
				<div class="btn">
					<span class="span_t">个人信息表</span>
					<a href="print_p_T.html" class="print">打印</a>
					<button class="change">修改</button>
					<button class="sure" onclick="checked();">确认</button>
					<div class="clear"></div>
				</div>
				<table border="1" id="com">
					<tr>
						<td class="one">姓名<span class="need">*</span></td>
						<td class="two"><input type="text" value="{{$result.username}}" name="username"></td>
						<td class="one">年龄<span class="need">*</span></td>
						<td class="two"><input type="text" value="{{if $result.params.age}}{{$result.params.age}}{{/if}}" name="params[age]"></td>
						<td class="one">性别<span class="need">*</span></td>
						<td class="two">
							<label for="man"><input type="radio" name="sex" {{if $result.sex == '0'}}checked="checked"{{/if}} id="man">男</label>
							<label for="woman"><input type="radio" {{if $result.sex == '1'}}checked="checked"{{/if}} name="sex" id="woman">女</label>
						</td>
					</tr>
					<tr>
						<td class="one">出生日期<span class="need">*</span></td>
						<td class="two"><input type="text" value="{{if $result.params.birthdate}}{{$result.params.birthdate}}{{/if}}" id="datepicker" name="params[birthdate]"></td>
						<td class="one">政治面貌<span class="need">*</span></td>
						<td class="two"><input type="text" value="{{if $result.params.political}}{{$result.params.political}}{{/if}}" name="params[political]"></td>
						<td class="one">民族<span class="need">*</span></td>
						<td class="two"><input type="text" value="{{if $result.params.nation}}{{$result.params.nation}}{{/if}}" name="params[nation]"></td>
					</tr>
					<tr>
						<td class="one">学历<span class="need">*</span></td>
						<td class="two"><input type="text" value="{{if $result.params.record}}{{$result.params.record}}{{/if}}" name="params[record]"></td>
						<td class="one">学位<span class="need">*</span></td>
						<td class="two"><input type="text" value="{{if $result.params.degree}}{{$result.params.degree}}{{/if}}" name="params[degree]"></td>
						<td class="one">导师类型<span class="need">*</span></td>
						<td class="two"><input type="text" value="{{if $result.params.teacher_type}}{{$result.params.teacher_type}}{{/if}}" name="params[teacher_type]"></td>
					</tr>
					<tr>
						<td class="one">工号</td>
						<td class="two"><input type="text" value="{{if $result.params.number}}{{$result.params.number}}{{/if}}" name="params[number]"></td>
						<td class="one">手机<span class="need">*</span></td>
						<td class="two"><input type="text" value="{{if $result.params.mobile}}{{$result.params.mobile}}{{/if}}" name="params[mobile]"></td>
						<td class="one">邮箱<span class="need">*</span></td>
						<td class="two"><input type="text" value="{{if $result.email}}{{$result.email}}{{/if}}" name="email"></td>
					</tr>
					<tr>
						<td class="one">职称<span class="need">*</span></td>
						<td class="two"><input type="text" value="{{if $result.params.professional}}{{$result.params.professional}}{{/if}}" name="params[professional]"></td>
						<td class="one"><span class="need">*</span>研究方向</td>
						<td class="two"><input type="text" value="{{if $result.params.direction}}{{$result.params.direction}}{{/if}}" name="params[direction]"></td>
						<td class="one">所属院系<span class="need">*</span></td>
						<td class="two"><input type="text" value="{{if $result.params.faculty}}{{$result.params.faculty}}{{/if}}" name="params[faculty]"></td>
					</tr>
					<tr>
						<td class="one">单位<span class="need">*</span></td>
						<td class="two" colspan="5"><input type="text" value="{{if $result.params.unit}}{{$result.params.unit}}{{/if}}" name="params[unit]"></td>
					</tr>
					<tr>
						<td class="one">家庭地址</td>
						<td class="two" colspan="5"><input type="text" value="{{if $result.params.address}}{{$result.params.address}}{{/if}}" name="params[address]"></td> 
					</tr>
					<tr>
						<td class="one">创业培训证书</td>
						<td class="two" colspan="5">
							<button class="download">
								<a href="javascript:;">附件</a>
							</button>
							<input type="file" class="upload" name="params[certificate]">
						</td> 
					</tr>
					<tr>
						<td class="one" rowspan="10" >
							所得奖项
							<div class="home email add_item">
								<svg class="icon" aria-hidden="true">
									<use xlink:href="#icon-icon-test"></use>
								</svg>
							</div>
						</td>
						<td class="three" colspan="3">奖项名称</td>
						<td class="one">级别</td>
						<td class="one">获奖时间</td>
					</tr>
					<tr class="no_company">
						<td colspan="6">无</td>
					</tr>
					{{if $result.params.teacher}}
					{{foreach from=$result.params.teacher item=val key=key}}
					<tr>
						<td colspan="3"><input type="text" name="params[teacher][reward_n][{{$key}}]" value="{{$val.reward_n}}"></td>
						<td><input type="text" value="{{$val.type_n}}" name="params[teacher][type_n][{{$key}}]"></td>
						<td>
							<input type="text"value="{{$val.time}}" name="params[teacher][time][{{$key}}]" style='width:80px;'>
							<a href='javascript:;' class='home email del' style="display:none;">
								<svg class='icon' style='color:red;' aria-hidden='true'>
									<use xlink:href='#icon-guanbi'></use>
								</svg>
							</a>
						</td>
					</tr>
					{{/foreach}}
					{{/if}}
				</table>
				</form>
			</div>
		</div>
		<div class="clear"></div>
	</div>
	<!-- 添加奖项窗口 -->
	<div class="transmit">
		<div class="main">
			<h4>添加奖项</h4>
			<div class="cont_m" style="height:150px;">
				<form action="" id="add_c">
					<table border="1px">
						<tr>
							<td >奖项名称<span class="need">*</span></td>
							<td class="one" colspan="5" style="width:100%;"><input type="text" name="name" value=""></td>
						</tr>
						<tr>
							<td class="one">级别<span class="need">*</span></td>
							<td class="three"><input type="text" name="xy_name" value=""></td>
							<td class="one">获奖时间 <span class="need">*</span></td>
							<td class="three"><input type="text" name="grade" value="" id="datepicker1"></td>
							<td></td>
						</tr>
						<tr>
							<td>操作</td>
							<td class="one" colspan="5" style="width:100%;">
								<div class="add btn_add can">添加</div>
							</td>
						</tr>
					</table>
				</form>
			</div>
			<div class="home close_tran">
				<svg class="icon" aria-hidden="true">
					<use xlink:href="#icon-guanbi"></use>
				</svg>
			</div>
			<span class="tosay"></span>
		</div>
	</div>
	<!-- 回到顶部 -->
	<div class="toTop"><span>↑</span>顶部</div>
	<script type="text/javascript">
	$(function(){
		$(".right input,.right textarea").attr("disabled","false").css("border","none");
		$(".add_item").hide();

		// 点击添加相应的窗口进行显示与影藏
		$(".add_item").click(function(){
			$(".transmit").show();
		})

		// 判断所获奖项是否需要显示“无”这一行
		if($("#com .del").length>0){
			$(".no_company").hide();
		}

		// 点击修改按钮时改变样式
		$(".change").click(function(){
			$("input,textarea").removeAttr("disabled").css("border","1px solid #D8D8D8");
			$(this).hide();
			$(".sure,.upload,.del,.add_item").show();
			$(".download").hide();
		})

		// 添加合伙人行函数
 		function add_company(name,input_n,xy_n,xy_v,grade_n,grade_v){
			var tr = "<tr><td colspan='3'><input value="+name+" name='"+input_n+"'></td><td><input type='text' name='"+xy_n+"' value="+xy_v+"/></td><td><input type='text' name='"+grade_n+"' value="+grade_v+" style='width:80px;'/><a href='javascript:;' class='home email del'><svg class='icon' style='color:red;' aria-hidden='true'><use xlink:href='#icon-guanbi'></use></svg></a></td></tr>";
			return tr;
		}

		// 点击添加合伙人进行验证信息
		$(".transmit input").blur(function(){
			if($("#add_c input[name='name']").val()==""){
				$(".tosay").html("用户名不能为空");
				return false;
			}else{
				$(".tosay").html("");
			}
		})	

   		// 添加合伙人
		$(".btn_add").click(function(){
			// 提取表单值
			var d = {};
		    var t = $("#add_c").serializeArray();
		    $.each(t, function() {
		      d[this.name] = this.value;
		    });
		    var name = JSON.stringify(d.name);  //输入的姓名
		    var xy_v = JSON.stringify(d.xy_name);//输入的学院名
		    var grade_v = JSON.stringify(d.grade);//输入的年级名

		    // 添加合伙人
		    $("#com").append(add_company(name,"params[teacher][reward_n][]","params[teacher][type_n][]",xy_v,"params[teacher][time][]",grade_v));

		    // 清除表单
			$("#add_c input[type='text']").val("");

			// 点击删除号删除相应的行
		    $(".del").click(function(){
				$(this).parent().parent("tr").remove();
				if($(".del").length<1){
					$(".no_company").show();
				}
			})
		   
		    // 添加合伙人后影藏弹框并且隐藏“无”一行
		    $(".transmit").hide();
		    if($("#com").find(".no_company").length==1){
		    	$(".no_company").hide();
		    }
		    $("input,textarea").removeAttr("disabled").css("border","1px solid #D8D8D8");
		})
		
		// 点击删除号删除相应的行
	    $(".del").click(function(){
			$(this).parent().parent("tr").remove();
			if($(".del").length<1){
				$(".no_company").show();
			}
		})

		// 日期调用
		laydate.render({
		  elem: '#datepicker' //指定元素
		});
		// 日期调用
		laydate.render({
		  elem: '#datepicker1' //指定元素
		});
	})
	//登录验证
	function checked(){
	    var params = $("#myform").serialize();
	    $.post('{{"index.php?app=Personal&act=teacher_info"|URL}}',params,function(result){
	        if(result.statusCode=='200'){
	        	ui.success(result.message);
	   			$(".right input,.right textarea").attr("disabled","false").css("border","none");
				$(".sure").hide();
				$(".change,.download").show();
				$(".upload,.del,.add_item").hide();
	        }else if(result.statusCode=='300'){
	        	ui.error(result.message)
	        }
	    },'json');
	};

	$("form").keydown(function(e){
		var curkey = e.which; 
		if(curkey == 13){ 
			checked();
		}
	}); 
	</script>
</body>
</html>